/*
----------------------------------------------------------------------------------------------------
This source file is part of the Gamut Framework
Copyright (c) 2007 by Ryan Holcombe

This program is free software; you can redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
----------------------------------------------------------------------------------------------------
*/


/* TO DO
1. Modify timer to work in WIN32 environment
2. Create a MAC compatible timer
*/


#ifndef _Timer_h_
#define _Timer_h_

#ifdef __linux__
	#include <sys/time.h>
	typedef struct timeval TIME;
#endif

#ifdef WIN32
	#include <windows.h>
	typedef struct LARGE_INTEGER TIME;
#endif


namespace Gamut
{

	/**
 		returns elapsed time in seconds, milliseconds, and microseconds
	*/

	class Timer
	{
	private:
			//! holds the start time
			TIME mBegin;

	public:

		/** Default Constructor
			\brief initialises the beginning time
		*/
		Timer();
		
		
		/**
			\brief resets the time back to 0
		*/
		void reset();
		
		
		/**
			\brief returns elapsed time in microseconds
		*/
		double getMicroSeconds();


		/**
			\brief returns elapsed time in milliseconds
		*/
		double getMilliSeconds() { return getMicroSeconds() / 1000.0; }		


		/**
			\brief returns elapsed time in seconds
		*/
		double getSeconds() { return getMicroSeconds() / 1000000.0; }		
	};
	
}


#endif
